package com.ourteam.product.requirement.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.requirement.dao.ProductIssueNoteDAOQueryBean;
import com.ourteam.product.requirement.domain.ProductIssueNoteBean;

public class ProductIssueNoteSearchModel extends AbstractSearchModel<ProductIssueNoteDAOQueryBean> {

	private long productIssueId;

	private String noteContent;

	public long getProductIssueId() {
		return productIssueId;
	}

	public void setProductIssueId(long productIssueId) {
		this.productIssueId = productIssueId;
	}

	public String getNoteContent() {
		return noteContent;
	}

	public void setNoteContent(String noteContent) {
		this.noteContent = noteContent;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductIssueNoteBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductIssueNoteDAOQueryBean queryBean) throws Exception {

		ProductIssueNoteDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (productIssueId != 0) {
			criteria.andIssueIdEqualTo(productIssueId);
		}

		if (StringUtils.isNotBlank(noteContent)) {
			criteria.andNoteContentLike(noteContent);
		}

	}

}
